package org.taofuxn.framework.mvp;

import android.os.Bundle;
import android.support.annotation.Nullable;

import org.taofuxn.framework.ui.base.BaseFragment;


/**
 * Created by wanghuafu on 16/9/15.
 */
public abstract class MvpFragment<P extends BasePresenter> extends BaseFragment {

    private P  mPresenter;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = createDefaultPresenter();
    }

    protected abstract P createDefaultPresenter();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mPresenter != null)
            mPresenter.onDetachView();
    }
}
